package xyz.xiaomeiqiu.study.domain;

import com.sun.org.apache.xpath.internal.operations.Or;

import java.math.BigDecimal;
import java.util.*;

public class OrderFactory {
    private final static Random amount = new Random(7);
    private final static Random userId = new Random(7);
    private final static Random money = new Random(7);
    private final static String status = "1";

    public static Order newOrder(){
        Order order = new Order();
        order.setT_order_code(UUID.randomUUID().toString());
        order.setT_order_amount(amount.nextInt(100));
        order.setT_order_status(status);
        order.setT_order_create_by(userId.nextLong());
        order.setT_user_id(userId.nextLong());
        order.setT_order_create_time(new Date());
        order.setT_order_price_final(String.valueOf(money.nextDouble()));
        order.setT_order_price_coupen(String.valueOf(money.nextDouble()));
        order.setT_order_price_origin(String.valueOf(money.nextDouble()));
        return order;
    }

    public static List<Order> newOrders(int num){
        List<Order> r = new ArrayList<>(num);
        for (int i = 0; i < num; i++) {
            r.add(newOrder());
        }
        return r;
    }
}
